﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;

namespace im.transwin7scr
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Window clientWindow = null;
            /*  /s – Start the screensaver in full-screen mode.
                /c – Show the configuration settings dialog box.
                /p #### – Display a preview of the screensaver using the specified window handle.
             */
           
            var test = HasArg("/t", e.Args);
            if (HasArg("/c", e.Args))
            {
                clientWindow = new ConfigWindow();
            }
            else if (HasArg("/s", e.Args))
            {
                clientWindow = new ScreenWindow(test, false, null);
            }
            if (clientWindow != null)
                clientWindow.Show();
            else
                Application.Current.Shutdown();
        }

        private bool HasArg(string arg, string[] args)
        {
            foreach (var a in args)
                if (a.IndexOf(arg) > -1)
                    return true;
            return false;
        }
    }
}
